package com.hainatong.shiphelper.mainhome;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import com.base.common.view.base.BaseActivity;
import com.base.common.viewmodel.BaseViewModel;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.gyf.immersionbar.ImmersionBar;
import com.hainatong.shiphelper.Constants;
import com.hainatong.shiphelper.R;
import com.hainatong.shiphelper.api.AppConstants;
import com.hainatong.shiphelper.databinding.ActivityCommonTitleBinding;
import com.hainatong.shiphelper.login.view.*;
import com.hainatong.shiphelper.mainhome.fragment.CommonResultFragment;
import com.hainatong.shiphelper.mainhome.fragment.YanxiDetailFragment;
import com.hainatong.shiphelper.module.OAmgr.OAMgrFragment;
import com.hainatong.shiphelper.module.OAmgr.fragment.ExamineFragment;
import com.hainatong.shiphelper.module.OAmgr.fragment.OABrokenApplyFragment;
import com.hainatong.shiphelper.module.OAmgr.fragment.OAShenPiApplyFragment;
import com.hainatong.shiphelper.module.handlejob.fragment.HandleTaskDetailFragment;
import com.hainatong.shiphelper.module.handlejob.fragment.HandleWorkFragment;
import com.hainatong.shiphelper.module.handlejob.fragment.MyHandleHistoryFragment;
import com.hainatong.shiphelper.module.handlejob.fragment.SignatureFragment;
import com.hainatong.shiphelper.module.handlejob.WorkMgrFragment;
import com.hainatong.shiphelper.module.holiday.fragment.FireWorkerFragment;
import com.hainatong.shiphelper.module.holiday.fragment.HolidayApplyResultFragment;
import com.hainatong.shiphelper.module.holiday.MyHolidayFragment;
import com.hainatong.shiphelper.module.holiday.fragment.NormalHolidayFragment;
import com.hainatong.shiphelper.mainhome.fragment.massage.ApprovalMsgFragment;
import com.hainatong.shiphelper.mainhome.fragment.massage.SysMsgFragment;
import com.hainatong.shiphelper.mainhome.fragment.massage.WarnMsgDetailFragment;
import com.hainatong.shiphelper.mainhome.fragment.massage.WarnMsgFragment;
import com.hainatong.shiphelper.module.QSHE.QSHEMgrFragment;
import com.hainatong.shiphelper.module.QSHE.fragment.DocumentFileFragment;
import com.hainatong.shiphelper.module.QSHE.fragment.SMISFragment;
import com.hainatong.shiphelper.module.cert.CertDetailFragment;
import com.hainatong.shiphelper.module.cert.CertMgrFragment;
import com.hainatong.shiphelper.module.cert.ChangeFragment;
import com.hainatong.shiphelper.module.holiday.fragment.VactionHistoryFragment;
import com.hainatong.shiphelper.module.warehouse.WareHouseMgrFragment;
import com.hainatong.shiphelper.module.warehouse.fragment.*;

import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import androidx.appcompat.widget.Toolbar;
import androidx.lifecycle.Observer;

import com.hainatong.shiphelper.module.workermgr.fragment.WorkerFragment;
import com.hainatong.shiphelper.utils.GsonUtil;
import com.hainatong.mvvmbase.rxbus.RxBus;
import com.hainatong.mvvmbase.rxbus.RxBusBaseMessage;
import com.hainatong.mvvmbase.utils.StatusBarUtils;
import com.jeremyliao.liveeventbus.LiveEventBus;



public class ComFragmentActivity extends BaseActivity<ActivityCommonTitleBinding, BaseViewModel> {
    private FragmentTransaction ft;

    public static void startViewByParam(Activity mContext, String viewType,String param,boolean isFinish)
    {
        Bundle bundle = new Bundle();
        bundle.putString( Constants.FRAGMNET_TYPE, viewType);
        bundle.putString( Constants.SCAN_CONTENT_CODE, param);
        start(mContext, bundle, isFinish);
    }

    public static void startViewByParam(Activity mContext, String viewType,String param)
    {
        Bundle bundle = new Bundle();
        bundle.putString( Constants.FRAGMNET_TYPE, viewType);
        bundle.putString( Constants.SCAN_CONTENT_CODE, param);
        start(mContext, bundle, false);
    }

    public static void startView(Activity mContext, String viewType)
    {
        Bundle bundle = new Bundle();
        bundle.putString( Constants.FRAGMNET_TYPE, viewType);
        start(mContext, bundle, false);
    }

    public static void start(Activity mContext, Bundle bundle) {
        start(mContext, bundle, false);
    }

    public static void start(Activity mContext, Bundle bundle, boolean isFinish) {
        Intent intent = new Intent();
        intent.setClass(mContext, ComFragmentActivity.class);
        if (bundle != null) intent.putExtra(mContext.getPackageName(), bundle);
        mContext.startActivity(intent);
        if (isFinish) {
            mContext.finish();
        }
    }

    public Bundle getBundle() {
        if (getIntent() != null && getIntent().hasExtra(getPackageName()))
            return getIntent().getBundleExtra(getPackageName());
        else
            return null;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_common_title);
    }

 
    /*
    @Override
    protected void initStatusBar() {
//        super.initStatusBar();
        ImmersionBar.with(this)
                .barEnable(false)
                .autoStatusBarDarkModeEnable(true)
                .autoNavigationBarDarkModeEnable(true)
                .fitsSystemWindows(true)
                .init();
    }
    */

    @Override
    protected int getStatusBarColor()
    {
        return R.color.login_bg;
    }

    @Override
    protected void setStatusBar(ImmersionBar in)
    {
        in.statusBarDarkFont(true)
          .barEnable(false)
          .fitsSystemWindows(true)
          .init();
        StatusBarUtils.setStatusBarDarkFont( this,true );
    }

    @Override
    protected void initView() {
        ft = getSupportFragmentManager().beginTransaction();

        Bundle bundle = getBundle();
        String type = bundle.getString(Constants.FRAGMNET_TYPE, "");

        String content = bundle.getString(Constants.SCAN_CONTENT_CODE, "");
        //Toolbar mToolbar =  binding.getRoot().findViewById( R.id.toolbar );
        //binding.includeTitle.toolbar
        if (!StringUtils.isEmpty(type)) {
            switch (type) {
                case Constants.USER_INFO:
                    openUserInfo(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.SET_PWD:
                    openChangePwd(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.HAND_PWD:
                    openHandlePassword(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.CHANGE_LANGUAGE:
                    openLanguageSelected(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.SIGN_NAME:
                    ToastUtils.showShort("登出");
                    break;
                // 功能列表

                case Constants.FUN_STOCK_OUT_IN_MGR:
                    openWareHouseMgr(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.FUN_HOLIDAY_MGR:
                    openHolidayMgr(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.FUN_WORK_MGR:
                    openWorkMgr(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.FUN_QSHE_MGR:
                    openQSHEMgr(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.FUN_CERT_MGR:
                    openCertMgr(binding.includeTitle.toolbar, ft);
                    break;

                // 仓库管理
                // 入库
                case Constants.VIEW_TYPE_RUKU:
                    if (!StringUtils.isEmpty(content)) {
                        openShelf(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                case Constants.VIEW_TYPE_RUKU_TASK:
                    if (!StringUtils.isEmpty(content)) {
                        openRukuTask(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                case Constants.VIEW_TYPE_CHUKU:
                    openChuKu(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.VIEW_TYPE_CHUKU_GOODS:
                    if (!StringUtils.isEmpty(content))
                    {
                        openChuKuGoodsTask(binding.includeTitle.toolbar, ft, content);
                    }
                    break;

                case Constants.VIEW_TYPE_RETURN:
                    if (!StringUtils.isEmpty(content)) {
                        openReturnAdd(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                case Constants.VIEW_TYPE_RETURN_TASK:
                    if (!StringUtils.isEmpty(content)) {
                        openReturnTask(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                case Constants.VIEW_TYPE_BROKEN_SUB:
                    if (!StringUtils.isEmpty(content)) {
                        openBrokenSub(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                case Constants.VIEW_TYPE_RUKU_ADD:
                    if (!StringUtils.isEmpty(content)) {
                        openRukuAdd(binding.includeTitle.toolbar, ft, content);
                    }
                    break;

                case Constants.VIEW_TYPE_LINGYONG_INFO:
                    openLinYongInfo(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.VIEW_TYPE_LINGYONG:
                    openLinYongRecord(binding.includeTitle.toolbar, ft);
                    break;

                case Constants.VIEW_SYS_MSG:
                    openSysMsg(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.VIEW_WARN_MSG:
                    openWarnMsg(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.VIEW_APRV_MSG:
                    openApprovalMsg(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.VIEW_WARN_MSG_DEATIL:
                    if (!StringUtils.isEmpty(content))
                    {
                        openWarnMsgDetail(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                case Constants.VIEW_NORMAL_HOLIDAY:
                    if (!StringUtils.isEmpty(content)) {
                        openNormalHoliday(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                case Constants.VIEW_NO_JOB:
                    if (!StringUtils.isEmpty(content))
                    {
                        openFireWorker(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                case Constants.VIEW_HOLIDAY_APPLY_DETAIL:
                    if (!StringUtils.isEmpty(content))
                    {
                        openApplyDetail(binding.includeTitle.toolbar, ft,content);
                    }
                    break;
                case Constants.VIEW_USER_VACATION_HISTORY:
                    if (!StringUtils.isEmpty(content))
                    {
                        openVactionHistory(binding.includeTitle.toolbar, ft,content);
                    }
                    break;

                case Constants.VIEW_HANDLE_JOB:
                    if (!StringUtils.isEmpty(content)) {
                        openHandleWork(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                case Constants.VIEW_HANDLE_HISTORY:
                    openMyHandleHistory(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.VIEW_SIGN_VIEW:
                    if (!StringUtils.isEmpty(content))
                    {
                        openSignView(binding.includeTitle.toolbar, ft ,content);
                    }
                    break;
                case Constants.VIEW_HANDLE_TASK_DETAIL:
                    if (!StringUtils.isEmpty(content))
                    {
                        openMyHandleDetail(binding.includeTitle.toolbar, ft ,content);
                    }
                    break;
                // QSHE
                case Constants.VIEW_SMIS_VIEW:
                    if (!StringUtils.isEmpty(content))
                    {
                        openSMISView(binding.includeTitle.toolbar, ft ,content);
                    }

                    break;
                case Constants.VIEW_DOCUMENT_VIEW:
                    if (!StringUtils.isEmpty(content))
                    {
                        openDocumentFile(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                // 证书管理
                case Constants.VIEW_CERT_DETAIL:
                    if (!StringUtils.isEmpty(content))
                    {
                        openCertDetail(binding.includeTitle.toolbar,ft,content);
                    }
                    break;
                case Constants.VIEW_CHANGE_CERT:
                    openChangeCert(binding.includeTitle.toolbar, ft);
                    break;

                // 选择仓库
                case Constants.VIEW_SELECT_WAREHOUSE:
                    openSelectWareHouse(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.VIEW_SELECT_SHELF:
                    if (!StringUtils.isEmpty(content))
                    {
                        openSelectShelf(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                // 选择 人员
                case Constants.VIEW_WORKER_SELECT_VIEW:
                    if (!StringUtils.isEmpty(content))
                    {
                        openWorkerSelect(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                //OA审批
                case Constants.VIEW_OA_MANAGER:
                    openOAMgr(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.VIEW_TO_EXAMINE:
                    openToExamine(binding.includeTitle.toolbar, ft);
                    break;
                case Constants.VIEW_OA_SHENPI_APPLY:
                    if (!StringUtils.isEmpty(content))
                    {
                        openOAShenPiApply(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                case Constants.VIEW_OA_BROKEN_APPLY:
                    if (!StringUtils.isEmpty(content))
                    {
                        openBrokenApply(binding.includeTitle.toolbar, ft, content);
                    }
                    break;
                //演习
                case Constants.VIEW_YANXI_STEP_DETAIL:
                    if (!StringUtils.isEmpty(content))
                    {
                        openYanxiDetail(binding.includeTitle.toolbar, ft, content);
                    }
                    break;

            }
        }


    }

    private void sendRxMsg(RxBusBaseMessage rxMsg)
    {
        RxBus.getDefault().post( Constants.COM_ATY_RXMSG_CODE , rxMsg);
    }


    @Override
    protected void initNotificationReceipt() {
        super.initNotificationReceipt();
        LiveEventBus.get(AppConstants.PWD_SUCCESS,Integer.class).observe(this, new Observer<Integer>() {
            @Override
            public void onChanged(Integer integer) {
                showResult(integer);
            }
        });

        //切换 各种 结果页面   （ 入库 出库 归还 等。。  ）
        LiveEventBus.get(Constants.VIEW_TYPE_COMMON_RESULT_TAG ,RxBusBaseMessage.class )
                    .observe(this,rxMsg -> {
                        showCommonResult( rxMsg );
                    });

    }



    /**
     * 显示 修改密码 结果
     *
     * @param pwdType
     */
    private void showResult(int pwdType) {
        ResultFragment resultFragment = new ResultFragment();
        Bundle bundle = new Bundle();
        bundle.putInt(Constants.PWD_SUCCESS_TYPE, pwdType);
        resultFragment.setArguments(bundle);
        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                resultFragment).commit();
    }

    public void showCommonResult(RxBusBaseMessage rxMsg)
    {
        CommonResultFragment comResultFrg =  CommonResultFragment.newInstance(GsonUtil.obj2json( rxMsg ));

        getSupportFragmentManager().beginTransaction()
                                   .replace(R.id.fragment_container,comResultFrg)
                                   .commitAllowingStateLoss();
    }


    @Override
    protected void initData()
    {
    }



    private void openUserInfo(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.m_user_info));
        setToolBar(toolbar);
        openFragment(mFt, new UserInfoFragment());
    }

    private void openChangePwd(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.change_pwd));
        setToolBar(toolbar);
        openFragment(mFt, new ChangePwdFragment());
    }

    private void openLanguageSelected(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.language_tag));
        setToolBar(toolbar);
        openFragment(mFt, new LanguageFragment());
    }

    private void openHandlePassword(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.set_handle_pwd));
        setToolBar(toolbar);
        openFragment(mFt, new HandlePwdFragment());
    }

    private void openFragment(FragmentTransaction mFt, Fragment fragment) {
        mFt.add(R.id.fragment_container, fragment).commit();
    }

    private void setToolbarTitle(Toolbar toolbar, String title) {
        // toolbar.setBackgroundColor(ContextCompat.getColor(this,R.color.red));

        ((TextView) toolbar.findViewById(R.id.tv_title)).setText(title);
        ((ImageButton) toolbar.findViewById(R.id.btn_back)).setImageResource(R.drawable.svg_back);
        toolbar.findViewById(R.id.btn_back).setOnClickListener(v -> {
            hideSoftInput();
            supportFinishAfterTransition();
        });
    }

    private void setToolbarSubButton(Toolbar toolbar, int resId, View.OnClickListener listener) {
        ((ImageButton) toolbar.findViewById(R.id.btn_sub)).setImageResource(resId);
        ((ImageButton) toolbar.findViewById(R.id.btn_sub)).setVisibility(View.VISIBLE);
        toolbar.findViewById(R.id.btn_sub).setOnClickListener(listener);
    }

    // 功能列表
    private void openWareHouseMgr(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.stock_out_in_mgr));
        setToolBar(toolbar);
        openFragment(mFt, new WareHouseMgrFragment());
    }

    private void openHolidayMgr(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.xiujia_mgr));
        setToolBar(toolbar);
        openFragment(mFt, new MyHolidayFragment());
    }

    private void openWorkMgr(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.work_mgr));
        setToolBar(toolbar);
        openFragment(mFt, new WorkMgrFragment());
    }

    private void openQSHEMgr(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.qshe_mgr));
        setToolBar(toolbar);
        openFragment(mFt, new QSHEMgrFragment());
    }

    private void openCertMgr(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.cert_mgr));
        setToolBar(toolbar);
        openFragment(mFt, new CertMgrFragment());
    }

    private void openCertDetail(Toolbar toolbar, FragmentTransaction mFt, String scanCode)
    {
        setToolbarTitle(toolbar, getString(R.string.cert_detail_str));
        setToolBar(toolbar);
        openFragment(mFt, CertDetailFragment.newInstance(scanCode));
    }

    private void openChangeCert(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.cert_detail_str));
        setToolBar(toolbar);
        openFragment(mFt, new ChangeFragment());
    }

    // 仓库管理
    // 入库
    /**************************** 仓库管理 *********************************/

    private void openShelf(Toolbar toolbar, FragmentTransaction mFt, String scanCode) {
        setToolbarTitle(toolbar, getString(R.string.fun_ruku));
        setToolBar(toolbar);
        openFragment(mFt, ShelfFragment.newInstance(scanCode));
    }

    private void openRukuTask(Toolbar toolbar, FragmentTransaction mFt, String scanCode) {
        setToolbarTitle(toolbar, getString(R.string.fun_ruku));
        setToolBar(toolbar);
        openFragment(mFt, RukuTaskFragment.newInstance(scanCode));
    }

    private void openChuKu(Toolbar toolbar, FragmentTransaction mFt)
    {
        setToolbarTitle(toolbar, getString(R.string.fun_chuku));
        setToolBar(toolbar);
        openFragment(mFt,new ChukuAddFragment());
    }

    private void openChuKuGoodsTask(Toolbar toolbar, FragmentTransaction mFt, String scanCode) {
        setToolbarTitle(toolbar, getString(R.string.fun_chuku));
        setToolBar(toolbar);
        openFragment(mFt, ChukuGoodsFragment.newInstance(scanCode));
    }


    private void openReturnAdd(Toolbar toolbar, FragmentTransaction mFt, String scanCode) {
        setToolbarTitle(toolbar, getString(R.string.fun_return));
        setToolBar(toolbar);
        openFragment(mFt, ReturnAddFragment.newInstance(scanCode));
    }

    private void openReturnTask(Toolbar toolbar, FragmentTransaction mFt, String scanCode) {
        setToolbarTitle(toolbar, getString(R.string.fun_return));
        setToolBar(toolbar);
        openFragment(mFt, ReturnTaskFragment.newInstance(scanCode));
    }

    private void openSelectWareHouse(Toolbar toolbar, FragmentTransaction mFt)
    {
        //getString(R.string.warn_msg)
        setToolbarTitle(toolbar, "选择仓库" );
        setToolbarSubButton(toolbar,R.mipmap.ic_scan_1,v -> {
            sendRxMsg(new RxBusBaseMessage(Constants.WH_SUB_SCAN_CODE ,"Click" ));
        });
        setToolBar(toolbar);
        openFragment(mFt, new SelectWareHouseFragment());
    }

    private void openSelectShelf(Toolbar toolbar, FragmentTransaction mFt,String scanCode)
    {
        //getString(R.string.warn_msg)
        setToolbarTitle(toolbar, "选择货架" );
        setToolBar(toolbar);
        openFragment(mFt, SelectShelfFragment.newInstance(scanCode));
    }

    /**************************** 仓库管理 *********************************/


    private void openBrokenSub(Toolbar toolbar, FragmentTransaction mFt, String scanCode) {
        setToolbarTitle(toolbar, getString(R.string.broken_submit));
        setToolBar(toolbar);
        openFragment(mFt, BrokenSubmitFragment.newInstance(scanCode));
    }

    private void openRukuAdd(Toolbar toolbar, FragmentTransaction mFt, String scanCode) {
        setToolbarTitle(toolbar, getString(R.string.fun_ruku));
        setToolBar(toolbar);
        openFragment(mFt, RukuAddFragment.newInstance(scanCode));
    }

    private void openLinYongInfo(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.select_lingyong_worker));
        setToolBar(toolbar);
        openFragment(mFt, new LinYongFragment());
    }

    private void openLinYongRecord(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.fun_linyongjilu));
        setToolBar(toolbar);
        openFragment(mFt, new LinYongRecordFragment());
    }

    private void openSysMsg(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.sys_msg));
        setToolBar(toolbar);
        openFragment(mFt, new SysMsgFragment());
    }

    private void openWarnMsg(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.warn_msg));
        setToolBar(toolbar);
        openFragment(mFt, new WarnMsgFragment());
    }

    private void openApprovalMsg(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.examine_msg));
        setToolBar(toolbar);
        openFragment(mFt, new ApprovalMsgFragment());
    }

    private void openWarnMsgDetail(Toolbar toolbar, FragmentTransaction mFt, String scanCode)
    {
        setToolbarTitle(toolbar, getString(R.string.stock_warn));
        setToolBar(toolbar);
        openFragment(mFt,  WarnMsgDetailFragment.newInstance(scanCode));
    }

    private void openNormalHoliday(Toolbar toolbar, FragmentTransaction mFt, String scanCode) {
        setToolbarTitle(toolbar, getString(R.string.xiujia));
        setToolBar(toolbar);
        openFragment(mFt, NormalHolidayFragment.newInstance(scanCode));
    }

    private void openFireWorker(Toolbar toolbar, FragmentTransaction mFt, String typeCode)
    {
        setToolbarTitle(toolbar, getString(R.string.can_not_job));
        setToolBar(toolbar);
        openFragment(mFt,  FireWorkerFragment.newInstance(typeCode));
    }


    private void openApplyDetail(Toolbar toolbar, FragmentTransaction mFt, String typeCode)
    {
        setToolbarTitle(toolbar, getString(R.string.xiujia_mgr));
        setToolBar(toolbar);
        openFragment(mFt,  HolidayApplyResultFragment.newInstance(typeCode));
    }

    private void openVactionHistory(Toolbar toolbar, FragmentTransaction mFt, String typeCode)
    {
        setToolbarTitle(toolbar, getString(R.string.xiujia_history));
        setToolBar(toolbar);
        openFragment(mFt,  VactionHistoryFragment.newInstance(typeCode));
    }

    /**************************** 值班交接 *********************************/
    private void openHandleWork(Toolbar toolbar, FragmentTransaction mFt, String typeCode) {
        setToolbarTitle(toolbar, getString(R.string.job_handle));
        setToolBar(toolbar);
        openFragment(mFt, HandleWorkFragment.newInstance(typeCode));
    }


    private void openMyHandleHistory(Toolbar toolbar, FragmentTransaction mFt) {
        setToolbarTitle(toolbar, getString(R.string.my_handle));
        setToolBar(toolbar);
        openFragment(mFt, new MyHandleHistoryFragment());
    }


    private void openSignView(Toolbar toolbar, FragmentTransaction mFt, String scanCode)
    {
        setToolbarTitle(toolbar, getString(R.string.signature_ok));
        setToolBar(toolbar);
        openFragment(mFt,  SignatureFragment.newInstance(scanCode));
    }

    private void openMyHandleDetail(Toolbar toolbar, FragmentTransaction mFt, String scanCode)
    {
        setToolbarTitle(toolbar, getString(R.string.my_handle_detail));
        setToolBar(toolbar);
        openFragment(mFt,  HandleTaskDetailFragment.newInstance(scanCode));
    }




    public void setToolBar(Toolbar toolbar) {

    }




    /**************************** QSHE *********************************/

    private void openSMISView(Toolbar toolbar, FragmentTransaction mFt , String scanCode) {
        setToolbarTitle(toolbar, getString(R.string.file_list));
        setToolBar(toolbar);
        openFragment(mFt, SMISFragment.newInstance(scanCode));
    }

    private void openDocumentFile(Toolbar toolbar, FragmentTransaction mFt, String typeCode) {
        setToolbarTitle(toolbar, getString(R.string.file_tag));
        setToolBar(toolbar);
        openFragment(mFt, DocumentFileFragment.newInstance(typeCode));
    }


    /**************************** QSHE *********************************/


    /**************************** 人员管理 *********************************/

    /**
     *  选择 人员
     * @param toolbar
     * @param mFt
     * @param typeCode
     */
    private void openWorkerSelect(Toolbar toolbar, FragmentTransaction mFt, String typeCode)
    {
        setToolbarTitle(toolbar, getString(R.string.worker_mgr_str));
        setToolBar(toolbar);
        openFragment(mFt, WorkerFragment.newInstance(typeCode));
    }


    /**************************** 人员管理 *********************************/

    /**************************** OA审批 *********************************/
    private void openOAMgr(Toolbar toolbar, FragmentTransaction mFt)
    {
        setToolbarTitle(toolbar, getString(R.string.oa_mgr));
        setToolBar(toolbar);
        openFragment(mFt,new OAMgrFragment());
    }

    //带审批
    private void openToExamine(Toolbar toolbar, FragmentTransaction mFt)
    {
        setToolbarTitle(toolbar, getString(R.string.examine_msg));
        setToolBar(toolbar);
        openFragment(mFt,new ExamineFragment());
    }

    // 审批页面
    private void openOAShenPiApply(Toolbar toolbar, FragmentTransaction mFt, String typeCode)
    {
        setToolbarTitle(toolbar, getString(R.string.detail));
        setToolBar(toolbar);
        openFragment(mFt, OAShenPiApplyFragment.newInstance(typeCode));
    }

    //破损 报废 审批页面
    private void openBrokenApply(Toolbar toolbar, FragmentTransaction mFt, String typeCode)
    {
        setToolbarTitle(toolbar, getString(R.string.detail));
        setToolBar(toolbar);
        openFragment(mFt, OABrokenApplyFragment.newInstance(typeCode));
    }


    /**************************** 演习 *********************************/
    private void openYanxiDetail(Toolbar toolbar, FragmentTransaction mFt, String typeCode)
    {
        setToolbarTitle(toolbar, getString(R.string.detail));
        setToolBar(toolbar);
        openFragment(mFt, YanxiDetailFragment.newInstance(typeCode));
    }


}
